#买入成功Xpath：    /html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div
import time

import pytest
from selenium.webdriver.common.by import By

from Auto.day02.login.Login_Operation import Login_Operation


class Finance_Operation(Login_Operation):
    text = ''

    @pytest.fixture(scope='function')
    def qixian_buy(self,login_driver,kind_name,pay_password,login_page):
        # self.logins(login_driver)
        # self.login_page(login_driver,username,password)
        login_driver.get('http://localhost:90/user/finance/toChangeMoney.html')
        # 相应名称的投资按钮
        login_driver.find_element(By.CSS_SELECTOR,
                                  f'button.btn.btn-primary.btn-sm.buy_btn[buybtnname="{kind_name}"]').click()
        time.sleep(1)
        login_driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/input').send_keys(pay_password)
        login_driver.find_element(By.XPATH, '//*[@id="layui-layer1"]/div[3]/a[1]').click()
        # 获取输出内容/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div
        time.sleep(1)
        self.text = login_driver.find_element(By.XPATH,
                                         '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div').text
        login_driver.find_element(By.XPATH,
                                  '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button').click()
        time.sleep(1)
    @pytest.fixture(scope='function')
    def jijin_buy(self,login_driver,kind_name,pay_password,login_page):
        login_driver.get('http://localhost:90/user/finance/toFundProduct.html')

        # 相应名称的投资按钮
        # 投资
        login_driver.find_element(By.CSS_SELECTOR,
                                  f'button.btn.btn-primary.btn-sm.buy_btn[buybtnname="{kind_name}"]').click()
        time.sleep(1)
        # 密码//*[@id="password"]/html/body/div[3]/div[2]/input
        login_driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/input').send_keys(pay_password)
        # chromeDriver.find_element(By.XPATH, '//div[@class="layui-layer-content"]//input[@id="password"]').send_keys(paypassword)
        login_driver.find_element(By.XPATH, '//*[@id="layui-layer1"]/div[3]/a[1]').click()
        # 获取输出内容/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div
        time.sleep(1)
        self.text = login_driver.find_element(By.XPATH,
                                         '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div').text

        login_driver.find_element(By.XPATH,
                                  '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button').click()
        time.sleep(1)
    def getResultMsg(self,login_driver):
        return self.text

